﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Vit.Mvc.Results
{
    public class PartialFeedResult : PartialViewResult
    {
        public bool IsClientCached { get; set; }

        public PartialFeedResult(string viewName, bool isClientCached)
        {
            ViewName = viewName;
            IsClientCached = isClientCached;
        }

        public override void ExecuteResult(ControllerContext context)
        {
            TempData = context.Controller.TempData;
            ViewData = context.Controller.ViewData;

            base.ExecuteResult(context);

            if (!IsClientCached)
            {
                context.HttpContext.Response.ContentType = "application/xml";
            }
            else
            {
                context.HttpContext.Response.StatusCode = 304;
                context.HttpContext.Response.SuppressContent = true;
            }
        }
    }
}
